Menu

Wiki usage

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
Edit Sidebar
Main > AITutorial

Main.AITutorial History

Show minor edits - Show changes to output

January 31, 2005, at 04:16 PM by bjarne
Changed line 256 from:
then just put in an '''red:animate/furniture/cardtable'''.then, make it solid by putting a clip around it, but make the clip 4 units inside of the tabletop because the AI might get stuck inside the table. No script models here guys. This is of UTMOST importance! Its targetname HAS to be ~~red:cardgame~~. Now, place 2 to 3 of any kind of AI in around the table. it doesnt matter if its allies or axis. But i havnt tested it on dogs yet. now give the AI any targetname you feel like. and they dont have to target anything.
to:
then just put in an '''animate/furniture/cardtable'''.then, make it solid by putting a clip around it, but make the clip 4 units inside of the tabletop because the AI might get stuck inside the table. No script models here guys. This is of UTMOST importance! Its targetname HAS to be '''cardgame'''. Now, place 2 to 3 of any kind of AI in around the table. it doesnt matter if its allies or axis. But i havnt tested it on dogs yet. now give the AI any targetname you feel like. and they dont have to target anything.
Changed lines 272-273 from:
BY:ILIKEFUNGUS (known at .map as Master-Of-Fungus-Foo-D)
to:

- [[Profiles/ilikefungus]] (known at .map as Master-Of-Fungus-Foo-D)
Changed line 277 from:
I tryed that and wondered why they don't play. But now (I had a look into the pak0.pk3) I found the solution. Just insert this line: '''red:exec global/cardgame.scr''' into your map's .scr file. One more error: the targetname of the cardtable has to be '''red:cardgame''' !!!
to:
I tryed that and wondered why they don't play. But now (I had a look into the pak0.pk3) I found the solution. Just insert this line: '''exec global/cardgame.scr''' into your map's .scr file. One more error: the targetname of the cardtable has to be '''cardgame''' !!!
Changed lines 279-281 from:
[ADDED BY: ati975]

Sry m8.. thanx for catching that... i guess i was in a hurry?
to:

- [[Profiles/ati975]]

Sry m8.. thanx for catching that... i guess i was in a hurry?

- [[Profiles/ilikefungus]]
January 25, 2005, at 12:59 AM by bjarne
Added lines 1-275:
!AI TUTORIAL
(:toc:)

!!Basic AI
In this tutorial we'll look at the basics of adding AI to your map. Later on we'll discuss things like Machinegunners's and alarms. Also it is assumed you have a basic knowledge of Radiant and scripting.

First off for those of you who don't know what info_pathnode's are, they are entities that set up a grid of paths that tell AI where they are allowed to roam. These are the basic for setting up AI. Now while some may tell you to put these everywhere on your map, it is only necessary to place them where the AI are and where you want them to go. They should be placed about waist high of the ground and can't be less than 32 units apart and no more than 384 units (I think) apart to be able to connect.

Now on with building a map to use as an example. I'll be showing you two ways to spawn AI. First make a large room about 1024 wide and 2048 long. And say 512 high. This should be textured with caulk. You should have something similar:

Img:aitut1.jpg

Now for light and fog. Add the following key/values to worldspawn:
||border=1
||!Key||!Value||
||ambientlight||30 30 30||
||farplane||1024||
Now texture the ground/floor face with a concrete texture only! (Ctrl + Shift + Click) Now for the wall faces, how about a nice plaster texture? Then a nice ceiling texture for the ceiling.

Next add an info_player_start at the South/bottom of the map.

Next we'll need two walls for the AI to spawn behind and run to you as they will appear out of nowhere. So place a caulk wall centered and a third of the way up that is 512 long and 256 high. Place a similar wall two thirds of the way up. You should have 256 units on either side to maneuver past the wall. Now texture these faces with a nice brick texture. You should have something similar:


Img:aitut2.jpg

Now you map is set up, so its time to add the actual AI. First you'll need pathnodes so the AI can get around. So place info>pathnodes everywhere in about a 256 unit grid set up like so:

Img:aitut3.jpg

There are two easy ways of spawning AI into your map. Both of them require a trigger. I will show you both ways, each one using one of the walls. First lets make a trigger. Place a trigger_multiple in front of the player_start. Next give it these key/values:
||border=1
||!Key||!Value||!Explanation||
||targetname||enemyspawnertrigger|| ||
||cnt||1||this way you can't keep triggering it and send out a zillion guys!||
||#set||1||identifies the set of AI's you are spawning with this trigger||

Img:aitut4.jpg

Now right click behind the wall and add an ai>actor. This is where the AI will spawn. It needs the following key/values:
||border=1
||!Key||!Value||!Explanation||
||targetname||enemyspawner|| ||
||#group||1||identifies the individual person in a set||
||#set||1|| ||
||model||human/german_elite_sentry.tik|| ||

Add two more ai>actors in this fashion. Except make the second and the third on have a #group of 2 and 3 respectively.

Next you want to tell these guys where to go once spawned. So find an info_pathnode on the other side of the wall and give it the key/value of:
||border=1
||!Key||!Value||
||targetname||enemyspawnerdestination||
||#group||1||
||#set||1||

Again do two more in this fashion. Also be sure to change the #group respectively. Now the guys are set up to go. Your screen should look like this: Img:aitut5.jpg

I think this second way is much easier than the first.

First make three 'ai>german>elite>sentry's behind the second wall. Give them these key/values:
||border=1
||!Key||!Value||
||targetname||enemyspawner||
||#set||100||

Next to tell them where to go. Select one of those guys and then select an info_pathnode to go to. Next hit 'Ctrl+K' to Konnect(:wink:) them together. Connect the other two guys to an info_pathnode in the same fashion. You should see a line connecting them together.

Next you need a trigger. Place a trigger_multiple with the first wall, but going all the way across, see the picture. Give it these key/values:
||border=1
||!Key||!Value||
||setthread||trigger100||
||targetname||trigger100||
||#set||100||

Your screen should look similar to this: Img:aitut6.jpg

Alright the mapping part is done. So save as test_ai_tut.map and then compile the map. Let's move onto scripting.

For the first method of spawning AI you'll need this in the script:
----
exec global/ai.scr //starts up the ai stuff
waittill prespawn
waittill spawn
thread global/ai.scr::spawngroup #1 #1 //spawn #set #group when corresponding #set is triggered
thread global/ai.scr::spawngroup #1 #2
thread global/ai.scr::spawngroup #1 #3
----
For the second method:
----
exec global/ai.scr //starts up the ai stuff
waittill prespawn
waittill spawn

trigger100:
thread global/ai.scr::spawnset 100 spawn100 //spawns all AI with #set/100
end
----

next you'll want some ammo to fight back:
----
waittill spawn
$player item weapons/mp40.tik//give player the MP40
$player ammo smg 128//give player 128 rounds of SMG ammo
$player useweaponclass smg//switch to the SMG
----
Now your final script should look like this.

----
//AI Tut
//script and map by blue60007
exec global/ai.scr //starts up the ai stuff
waittill prespawn
waittill spawn
$player item weapons/mp40.tik//give player the MP40
$player ammo smg 128//give player 128 rounds of SMG ammo
$player useweaponclass smg//switch to the SMG
//spawn #set #group when corresponding #set is triggered
thread global/ai.scr::spawngroup #1 #1
thread global/ai.scr::spawngroup #1 #2
thread global/ai.scr::spawngroup #1 #3

//trigger set 100
trigger100:
//spawns all AI with #set/100
thread global/ai.scr::spawnset 100 spawn100
end
----

This should hopefully get you started!

----
'''added on ai tutorial by [[Profile/reptilian_mapper]], known at .map as lizardkid'''
----

This tut should be able to show you how to 'script spawn' ai.
first off create a room, i prefer to use a U shaped room about 1800 x 1200. (x axis, y axis)

now, enclose it up and create some cover, sandbags and small brushes and tables work wonders for indoor maps. as do crates.

put an info>player>start at the 'southern' end of the U (the bottom end on default Radient settings)

now, place a trigger_multiple about halfway through the player's end of the U. give it the following keys/values
||border=1
||!Key||!Value||
||cnt||1||
||targetname||spawner1||
||setthread||scriptspawn1||

now, make a few ai_actors where you want the germans to appear.position them as you want and copy/paste their origins (Entity properties, origin) to Notepad. we'll use them later. delete them, we don't need and probably isn't a good idea to leave actors where the ai are to spawn.

hit N for Entity once more, make sure you have nothing selected (hit Escape) and scroll all the way down until you reach worldspawn. click on it. give it the following values....
||border=1
||!Key||!Value||
||gravity||700||
||ambientlight||80 80 80||

ambient light it faster than a ton of light entities because it affects the whole level, not just certain spheres, and it doesn't cast shadows. it's a sloppier method but if your map is small and especially a test map like this, it can benifit greatly from ambient light.
the gravity is my preferred gravity level, i feel that 800 restricts jumping too much. this is my preference and you can exempt it if you like.

that's it for mapping, save the map as test_spawnmap and we'll move onto scripting.

place this script into notepad and put in your formor ai_actor's origins in where noted....
----
main:
exec global/ai.scr
exec global/loadout.scr maps/test_spawnmap.scr
level waittill prespawn
exec global/ambient.scr test_spawnmap
level waittill spawn
level.script = "maps/test_spawnmap.scr"
thread guns
end //end finishes a thread, the main thread is called from the programming
//at the start of the level.

guns:
$player item weapons/colt45.tik //gives the player a colt .45
$player ammo pistol 200 //gives the player 200 rounds of pistol ammo
end

scriptspawn1:
spawn models/human/german_wehrmact_soldier.tik "gun" "stg44" "origin" ""
//in the empty "" place your first ai_actor's origins in there.
//just copy/paste from your other notepad.
//spawn command can be used for anything.. roaches, ai, mortars...

//if wanted, put more spawn commands and origins around here,
//just make sure to put in their origins differently
//so they don't get stuck in each other.
end
----
that's it!! compile your map and try it out! you should feel a slight pause when you hit the trigger as the computer needs to actually place the guy.

the reasons you'd want to do script spawning as opposed to regular spawning are simple, this bypasses a ton of sub-routines and goes straight to spawning, no sidetracks needed. thus in the long run this sort of spawning is slightly faster.

it's also good practice for spawning stuff besides ai too, like i said anything can be spawned, mortar dust, lights, pathnodes... anything besides a brush is spawnable via this method. just find the modelname and replace

human/german_wehrmact_soldier.tik

with the modelname of what you'd like to spawn.

have fun on this! [[Profile/reptilian_mapper]]

----
'''Blue60007 has kindly allowed me to continue on this AI page.
in this section we'll discuss mg42 gunners. most of this is very simple and it's almost all taken care of by other scripts. we only need to set this up.'''
----

first of all create an L shaped room, really doesn't matter the soze, make sure though that the player can mov around adequately and there's room for cover.

alright, in the lower part of the L make an info>player>start and texture this little L-box up.

now, put a waist-high brush at the opposite end of the L (away from the end of it) and texture as needed.
now all we need is our gunner and gun. you can script spawn or spawnset spawn your gunner however you like. you don't even need to spawn him if you dont want to.
for convienience, i'll jsut put him in manually. right click ai>german>panzer>grenadier.
in the ai properties window find a list of type_ prefixes in the top right. there ought to be four of them, idle, grenade, and disguise., set to machinegunner. type_attack set to turret.
in the $targetname window put

gunny

and in the target window put

gun

alright. now for the mg42. find the bipod at playerweapon>german>mg42bipod and palce it on your little waist-high brush. find th actual gun at turretweapon>german>mg42. line them up as best as you can so that their arrows are lined up and they have an accurate distance from the muzzle. i've found the second 'air-hole' works fine.
so now they ought to be lined up perfectly so that you can't tell they're separete. the arrows are where the entity 'is', they determine the point around which the entity will turn, so where the force is going to be least. so point those two arrows in the direction you wish (to the left, down the L)
now selsect the mg42 and put in the following keys/values in the Entity window (press 'N')

||border=1
||!Key||!Value||
||targetname||gun||

okay, you ought to see a line connecting the ai with the gun.

and voila, one death-spraying bullet hound is ready to harass your poor player!

a hint on how to use mg42 gunners:
mg42's work best a medium-long distance where smg/mg cant reach very effectively. this means that placing them 2 inches from your player is not going to be very effective in challenge. the waited time the gunner has to wait until he shoots is plenty of time to get the player firing.
they also work good for covering and supressing fire. you'll learn more about how to do this later. for now, the gunner will do a pretty good job with keeping the player busy.

cheers. [[Profile/reptilian_mapper]]

!!Making the ai roll in the poker chips
Playing cards

Its fun its easy and even work with the allies(Just DONT put them in the same room).Lets get started, shall we?
Firstofall, lets make a basic room, which i hope we all know how to make, with any texture you want.

Img:pic1b.jpg

then just put in an '''red:animate/furniture/cardtable'''.then, make it solid by putting a clip around it, but make the clip 4 units inside of the tabletop because the AI might get stuck inside the table. No script models here guys. This is of UTMOST importance! Its targetname HAS to be ~~red:cardgame~~. Now, place 2 to 3 of any kind of AI in around the table. it doesnt matter if its allies or axis. But i havnt tested it on dogs yet. now give the AI any targetname you feel like. and they dont have to target anything.
Ok, now select the cardtable and THEN the AI and hit ctrl+k. you should see a sea-green line going to the AI. now, If you want to see your card guys in action, lower their awareness,hearing,and filed of vision down to 1. Now add in the extras like some static light fixtures, a few empty tables and some light entities, and all that fancy stuff. your radiant should .look something like this:

Img:pic2b.jpg

Ok now in here is a script for it.

----
main:
exec global/cardgame.scr
level waittill prespawn
level waittill spawn
end
----

now compile it and you should see three guys playing cards! END
BY:ILIKEFUNGUS (known at .map as Master-Of-Fungus-Foo-D)

!!The AI won't play?

I tryed that and wondered why they don't play. But now (I had a look into the pak0.pk3) I found the solution. Just insert this line: '''red:exec global/cardgame.scr''' into your map's .scr file. One more error: the targetname of the cardtable has to be '''red:cardgame''' !!!
Tested and it worx! Now have fun!!!
[ADDED BY: ati975]

Sry m8.. thanx for catching that... i guess i was in a hurry?

Recent Changes Printable View Page History Edit Page [Attributes] [Printable View] [WikiHelp]
Page last modified on August 12, 2005, at 10:43 AM